home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 August / DPPCPRO0805.ISO / Assets / Interface / Main.dxr / Movie Scripts_4_Flash interactions- set content.ls < prev    next >
Encoding:
Text File  |  2005-05-20  |  5.4 KB  |  136 lines

  1. global dataSource, handlerStore
  2.  
  3. on setContent
  4.   numPages = dataSource.xmlData["disc"]["pages"].child.count
  5.   numSections = dataSource.xmlData["disc"]["sections"].child.count
  6.   if numPages > 1 then
  7.     repeat with pageNum = 1 to dataSource.xmlData["disc"]["pages"].count
  8.       if dataSource.xmlData["disc"]["pages"].child[pageNum].attributeValue["name"] = "sections" then
  9.         sectionsPage = pageNum
  10.       end if
  11.     end repeat
  12.     if sectionsPage <> 1 then
  13.       repeat with pageNum = 1 to sectionsPage - 1
  14.         currentPage = dataSource.xmlData["disc"]["pages"].child[pageNum]
  15.         sprite("Content pane").setSection(currentPage.attributeValue["name"])
  16.       end repeat
  17.     end if
  18.     setSections(sectionsPage)
  19.     if sectionsPage < numPages then
  20.       repeat with pageNum = sectionsPage + 1 to numPages
  21.         sprite("Content pane").setSection(dataSource.xmlData["disc"]["pages"].child[pageNum].attributeValue["name"])
  22.       end repeat
  23.     end if
  24.   else
  25.     sectionsPage = 1
  26.     setSections(sectionsPage)
  27.   end if
  28.   repeat with sectionNum = 1 to numSections
  29.     numEntries = dataSource.xmlData["disc"]["sections"].child[sectionNum]["entries"].child.count
  30.     repeat with entryNum = 1 to numEntries
  31.       currentEntry = dataSource.xmlData["disc"]["sections"].child[sectionNum]["entries"].child[entryNum]
  32.       if currentEntry["shorttitle"] <> VOID then
  33.         listTitle = currentEntry["shorttitle"].child[1].toString()
  34.       else
  35.         listTitle = currentEntry["title"].child[1].toString()
  36.       end if
  37.       actualSectionNum = sectionsPage + sectionNum - 1
  38.       sprite("Content pane").setApp(actualSectionNum, listTitle)
  39.       descText = removeOuterTags(currentEntry.toString())
  40.       sprite("Content pane").setAppAttribute(sectionNum, entryNum, "description", descText)
  41.       numLinks = currentEntry["links"].child.count
  42.       repeat with linkNum = 1 to numLinks
  43.         setLink(sectionNum, entryNum, linkNum, currentEntry["links"].child[linkNum])
  44.       end repeat
  45.       if currentEntry["footer"]["column1"] <> VOID then
  46.         column1Text = removeOuterTags(currentEntry.toString())
  47.         sprite("Content pane").setAppAttribute(sectionNum, entryNum, "column1", column1Text)
  48.         if currentEntry["footer"]["column2"] <> VOID then
  49.           column2Text = removeOuterTags(currentEntry.toString())
  50.           sprite("Content pane").setAppAttribute(sectionNum, entryNum, "column2", column2Text)
  51.         end if
  52.       end if
  53.     end repeat
  54.   end repeat
  55. end
  56.  
  57. on setSections sectionsPage
  58.   numSections = dataSource.xmlData["disc"]["sections"].child.count
  59.   repeat with pageNum = 1 to numSections
  60.     currentSection = dataSource.xmlData["disc"]["sections"].child[pageNum]
  61.     sprite("Content pane").setSection(currentSection.attributeValue["name"])
  62.     if currentSection["intro"] <> VOID then
  63.       setSectionIntro(sectionsPage + pageNum - 1, currentSection)
  64.     end if
  65.   end repeat
  66. end
  67.  
  68. on setSectionIntro secNum, section
  69.   introDesc = removeOuterTags(section["intro"]["main"])
  70.   if section["intro"]["footer"] <> VOID then
  71.     footerDesc = removeOuterTags(section["intro"]["footer"].toString())
  72.   else
  73.     footerDesc = VOID
  74.   end if
  75.   highlights = findNodesWithAttr(section["entries"], "highlight", "true")
  76.   if highlights.count <> 0 then
  77.     setHighlights(secNum, highlights)
  78.   end if
  79.   updates = findNodesWithAttr(section["entries"], "updated", "true")
  80.   if updates.count <> 0 then
  81.     setUpdates(secNum, updates)
  82.   end if
  83. end
  84.  
  85. on setHighlights secNum, highlights
  86.   repeat with hlNum = 1 to highlights.count
  87.     if highlights[hlNum].node["shorttitle"] <> VOID then
  88.       hlTitle = highlights[hlNum].node["shorttitle"].child[1].toString()
  89.     else
  90.       hlTitle = highlights[hlNum].node["title"].child[1].toString()
  91.     end if
  92.     hlDesc = removeOuterTags(highlights[hlNum].node["highlight"].toString())
  93.     hlImage = getVolume() & highlights[hlNum].node["highlight"].attributeValue["src"]
  94.     sprite("Content pane").setHighlight(secNum, hlNum, hlTitle, hlDesc, hlImage, highlights[hlNum].childNum)
  95.   end repeat
  96. end
  97.  
  98. on setUpdates secNum, updates
  99.   repeat with updNum = 1 to updates.count
  100.     sprite("Content pane").setUpdate(secNum, updates[updNum].childNum, updates[updNum].node["title"].child[1].toString())
  101.   end repeat
  102. end
  103.  
  104. on findNodesWithAttr parentNode, attrName, attrValue
  105.   matchingNodes = []
  106.   repeat with childNum = 1 to parentNode.child.count
  107.     currentNode = parentNode.child[childNum]
  108.     if currentNode.attributeValue[attrName] = attrValue then
  109.       matchingNodes.add([#node: currentNode, #childNum: childNum])
  110.     end if
  111.   end repeat
  112.   return matchingNodes
  113. end
  114.  
  115. on assembleHTMLText parentNode
  116.   htmlText = EMPTY
  117.   repeat with childNum = 1 to parentNode.child.count
  118.     htmlText = htmlText & parentNode.child[childNum].toString()
  119.   end repeat
  120.   return htmlText
  121. end
  122.  
  123. on setLink sectionNum, entryNum, linkNum, currentLink
  124.   if currentLink.child.count <> 0 then
  125.     sprite("Content pane").setComplexLink(sectionNum, entryNum, linkNum, currentLink.attributeValue["label"])
  126.     repeat with stepNum = 1 to currentLink.child.count
  127.       stepDesc = removeOuterTags(currentLink.child[stepNum].toString())
  128.       stepLabel = currentLink.child[stepNum].attributeValue["label"]
  129.       stepTarget = currentLink.child[stepNum].attributeValue["href"]
  130.       sprite("Content pane").setStep(sectionNum, entryNum, linkNum, stepDesc, stepLabel, stepTarget)
  131.     end repeat
  132.   else
  133.     sprite("Content pane").setSimpleLink(sectionNum, entryNum, currentLink.attributeValue["label"], currentLink.attributeValue["href"])
  134.   end if
  135. end
  136.